package com.example.library_base.util

import android.view.MotionEvent
import android.view.View
import android.widget.EditText

object KeyBoardUtil {

    //判断是否需要隐藏软键盘
    fun isKeyBoardHide(view: View?, event: MotionEvent): Boolean{
        if (view != null && view is EditText) {
            val leftTop = intArrayOf(0, 0)
            view.getLocationInWindow(leftTop)
            val left = leftTop[0]
            val top = leftTop[1]
            val bottom: Int = top + view.getHeight()
            val right: Int = left + view.getWidth()
            return !(event.x > left && event.x < right && event.y > top && event.y < bottom)
        }
        return false
    }
}